ccR.Add_Rotation(
	3, -- specialization
	"ccR_CC_Paladin_3_PVE_Solo", -- function
	"Retribution for Levelling/Dungeons", -- Description
	"CC_Paladin_Retribution_Talents", -- Talents
	"CC_Paladin_Retribution_Abilities", -- Abilities
	"CC_Paladin_Retribution_Features", -- Features
	"CC_Paladin_Retribution_Setup" -- Setup
)
function ccR_CC_Paladin_3_PVE_Solo()
	if ccR.Player.Is.InCombat() then
		ccR.Start_Attack()
		-- Talents
		-- Paladin\Talents.lua
			if ccR.Var("Blinding_Light") then ccR.Paladin.Talent.Blinding_Light(ccR.Var("Blinding_Light_Count")) end
			if ccR.Var("Selfless_Healer") then ccR.Paladin.Talent.Selfless_Healer(ccR.Var("Selfless_Healer_Health")) end
			if ccR.Var("Sacred_Shield") then ccR.Paladin.Talent.Sacred_Shield(ccR.Var("Sacred_Shield_Health")) end
			if ccR.Var("Hand_of_Purity") then ccR.Paladin.Talent.Hand_of_Purity(ccR.Var("Hand_of_Purity_Health")) end
			if ccR.Var("Holy_Avenger") then if not ccR.Var("Holy_Avenger_BossOnly") or (ccR.Var("Holy_Avenger_BossOnly") and (ccR.Target.Is.Boss() or ccR.Player.Is.Solo())) then ccR.Paladin.Talent.Holy_Avenger() end end
			if ccR.Var("Holy_Prism") then ccR.Paladin.Talent.Holy_Prism(ccR.Var("Holy_Prism_Count")) end
			if ccR.Var("Lights_Hammer") then ccR.Paladin.Talent.Lights_Hammer(ccR.Var("Lights_Hammer_Count")) end
		-- Features
		-- Paladin\Features.lua
			if ccR.Var("Word_of_Glory") then ccR.Paladin.Feature.Word_of_Glory(ccR.Var("Word_of_Glory_Health"), 3) end
			if ccR.Var("Cleanse") then ccR.Paladin.Feature.Cleanse() end 
			if ccR.Var("Avenging_Wrath") then if not ccR.Var("Avenging_Wrath_BossOnly") or (ccR.Var("Avenging_Wrath_BossOnly") and (ccR.Target.Is.Boss() or ccR.Player.Is.Solo())) then ccR.Paladin.Feature.Avenging_Wrath() end end
			if ccR.Var("Rebuke") then ccR.Paladin.Feature.Rebuke(ccR.Var("Rebuke_Time")) end 
			if ccR.Var("Hammer_of_Wrath") then ccR.Paladin.Feature.Hammer_of_Wrath() end
			if ccR.Var("Hand_of_Freedom") then ccR.Paladin.Feature.Hand_of_Freedom() end
			if ccR.Var("Divine_Protection") then ccR.Paladin.Feature.Divine_Protection(ccR.Var("Divine_Protection_Health")) end 
			if ccR.Var("Divine_Shield") then ccR.Paladin.Feature.Divine_Shield(ccR.Var("Divine_Shield_Health")) end 
			if ccR.Var("Lay_on_Hands") then ccR.Paladin.Feature.Lay_on_Hands(ccR.Var("Lay_on_Hands_Health")) end 
			if ccR.Var("Hand_of_Protection") then ccR.Paladin.Feature.Hand_of_Protection(ccR.Var("Hand_of_Protection_Health")) end 
	end

	-- AoE Rotation
	if (ccR.Var("AutoAoE") and not ccR.Target.Is.Boss() and ((ccR.Player.Has.Buff(FINAL_VERDICT) and ccR.Player.Count(16) >= ccR.Var("AoECount")) or (not ccR.Player.Has.Buff(FINAL_VERDICT) and ccR.Player.Count(8) >= ccR.Var("AoECount")))) 
	or ccR.Var("ManualAoE")
	then
		if ccR.Spell.Is.Ready(DIVINE_STORM) and (ccR.Player.Holy_Power() >= 5 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF) or ccR.Player.Has.Buff(DIVINE_CRUSADER)) then 
			if ccR.Player.Has.Talent(FINAL_VERDICT) then
				if not ccR.Player.Has.Buff(FINAL_VERDICT) then
					if ccR.Spell.CanAttack(FINAL_VERDICT) then
						ccR.Cast.Attack(FINAL_VERDICT)
					else
						for x =1, # ccR_Enemies_Within_10 do
							local vUnit = ccR_Enemies_Within_10[x]
							if ccR.Unit.Is.Attackable(vUnit)
							and (ccR.Player.Is.Facing(vUnit) or ccR.Var("fh_Always_Facing"))
							and ccR.Spell.CanAttack(FINAL_VERDICT, vUnit)
							then
								ccR.Cast.Attack(FINAL_VERDICT, vUnit)	
							end
						end
					end
				else
					ccR.Cast.Spell(DIVINE_STORM)
					
				end
			else
				ccR.Cast.Spell(DIVINE_STORM) 
				
			end
		end
		if ccR.Target.Is.Attackable() then
			if (ccR.Player.Is.Facing("target") or ccR.Var("fh_Always_Facing")) then
				ccR.Paladin.Talent.Execution_Sentence() 
				if ccR.Spell.CanAttack(HAMMER_OF_WRATH) and ccR.Player.Holy_Power() < 5 and	((not ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 20) or (ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 35)	or ccR.Player.Has.Buff(AVENGING_WRATH))	then ccR.Cast.Attack(HAMMER_OF_WRATH) 
				elseif ccR.Spell.CanAttack(HAMMER_OF_THE_RIGHTEOUS) then ccR.Cast.Attack(HAMMER_OF_THE_RIGHTEOUS) 
				elseif ccR.Spell.CanAttack(EXORCISM) and ccR.Player.Holy_Power() < 5 and not ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(EXORCISM) 
				end
			end
			if ccR.Spell.CanAttack(JUDGMENT) and ccR.Player.Holy_Power() < 5 then ccR.Cast.Attack(JUDGMENT)  end
		end
		if ccR.Spell.Is.Ready(MASS_EXORCISM) and ccR.Player.Holy_Power() < 5 and ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(MASS_EXORCISM)  end
		-- Final Verdict buff before Divine Storm
		if ccR.Spell.Is.Ready(DIVINE_STORM)	and (ccR.Player.Holy_Power() >= 3 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF) or ccR.Player.Has.Buff(DIVINE_CRUSADER)) then
			if ccR.Player.Has.Talent(FINAL_VERDICT) then
				if not ccR.Player.Has.Buff(FINAL_VERDICT) then
					if ccR.Spell.CanAttack(FINAL_VERDICT) then
						ccR.Cast.Attack(FINAL_VERDICT)
						
					else
						for x =1, # ccR_Enemies_Within_10 do
							local vUnit = ccR_Enemies_Within_10[x]
							if ccR.Unit.Is.Attackable(vUnit)
							and (ccR.Player.Is.Facing(vUnit) or ccR.Var("fh_Always_Facing"))
							and ccR.Spell.CanAttack(FINAL_VERDICT, vUnit)
							then
								ccR.Cast.Attack(FINAL_VERDICT, vUnit)
								
							end
						end
					end
				else
					ccR.Cast.Spell(DIVINE_STORM) 
					
				end
			else
				ccR.Cast.Spell(DIVINE_STORM) 
				
			end
		end
		-- Exorcism
		if ccR.Target.Is.Attackable() then
			if (ccR.Player.Is.Facing("target") or ccR.Var("fh_Always_Facing")) then
				if ccR.Spell.CanAttack(HAMMER_OF_WRATH) and	((not ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 20) or (ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 35)	or ccR.Player.Has.Buff(AVENGING_WRATH))	then ccR.Cast.Attack(HAMMER_OF_WRATH) 
				elseif ccR.Spell.CanAttack(EXORCISM) and not ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(EXORCISM) 
				elseif ccR.Spell.CanAttack(JUDGMENT) then ccR.Cast.Attack(JUDGMENT)  
				end
			end
		end
		if ccR.Spell.Is.Ready(MASS_EXORCISM) and ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(MASS_EXORCISM)  end
	
	end

	-- Single Target Rotation
	if ccR.Player.Has.Buff(DIVINE_CRUSADER) and ccR.Spell.Is.Ready(DIVINE_STORM) and ((ccR.Player.Has.Buff(FINAL_VERDICT) and ccR.Player.Count(16) >= 1) or (not ccR.Player.Has.Buff(FINAL_VERDICT) and ccR.Player.Count(8) >= 1)) then ccR.Cast.Spell(DIVINE_STORM)  end
	if ccR.Target.Is.Attackable() then
		if (ccR.Player.Is.Facing("target") or ccR.Var("fh_Always_Facing")) then
			if ccR.Player.Has.Talent(SERAPHIM) then
				if ccR.Player.Holy_Power() == 5 and ccR.Spell.Is.Ready(SERAPHIM) and not ccR.Player.Has.Buff(SERAPHIM) then	ccR.Cast.Spell(SERAPHIM)  end
				if ccR.Player.Has.Buff(SERAPHIM) or ccR.Spell.Is.OnCooldown(SERAPHIM) then
					if (ccR.Player.Holy_Power() >= 5 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(TEMPLARS_VERDICT) then ccR.Cast.Attack(TEMPLARS_VERDICT)  end
				end
			else
				if ccR.Player.Has.Talent(FINAL_VERDICT) then if (ccR.Player.Holy_Power() >= 5 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(FINAL_VERDICT) then ccR.Cast.Attack(FINAL_VERDICT)  end else if (ccR.Player.Holy_Power() >= 5 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(TEMPLARS_VERDICT) then ccR.Cast.Attack(TEMPLARS_VERDICT)  end end
			end
			ccR.Paladin.Talent.Execution_Sentence()
			if ccR.Player.Holy_Power() < 5 then
				if ccR.Spell.CanAttack(JUDGMENT) then ccR.Cast.Attack(JUDGMENT) 
				elseif ccR.Spell.CanAttack(HAMMER_OF_WRATH) and ((not ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 20) or (ccR.Player.Has.Spell(EMPOWERED_HAMMER_OF_WRATH) and ccR.Target.Health() <= 35)	or ccR.Player.Has.Buff(AVENGING_WRATH))	then ccR.Cast.Attack(HAMMER_OF_WRATH) 
				elseif ccR.Spell.CanAttack(EXORCISM) and not ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(EXORCISM) 
				elseif ccR.Spell.CanAttack(MASS_EXORCISM) and ccR.Player.Has.Glyph(GLYPH_OF_MASS_EXORCISM) then ccR.Cast.Attack(MASS_EXORCISM) 
				end
			end
			if ccR.Player.Has.Talent(SERAPHIM) then
				if ccR.Player.Holy_Power() == 5 and ccR.Spell.Is.Ready(SERAPHIM) and not ccR.Player.Has.Buff(SERAPHIM) then	ccR.Cast.Spell(SERAPHIM) end
				if ccR.Player.Has.Buff(SERAPHIM) or ccR.Spell.Is.OnCooldown(SERAPHIM) then
					if (ccR.Player.Holy_Power() >= 3 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(TEMPLARS_VERDICT) then ccR.Cast.Attack(TEMPLARS_VERDICT)  end
				end
			else
				if ccR.Player.Has.Talent(FINAL_VERDICT) then if (ccR.Player.Holy_Power() >= 3 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(FINAL_VERDICT) then ccR.Cast.Attack(FINAL_VERDICT)  end else if (ccR.Player.Holy_Power() >= 3 or ccR.Player.Has.Buff(DIVINE_PURPOSE_BUFF)) and ccR.Spell.CanAttack(TEMPLARS_VERDICT) then ccR.Cast.Attack(TEMPLARS_VERDICT)  end	end
			end
			if ccR.Target.Count(8) == 1 and ccR.Spell.CanAttack(CRUSADER_STRIKE) then ccR.Cast.Attack(CRUSADER_STRIKE)  end
			if ccR.Target.Count(8) >= 2 and ccR.Spell.CanAttack(HAMMER_OF_THE_RIGHTEOUS) then ccR.Cast.Attack(HAMMER_OF_THE_RIGHTEOUS)  end
			ccR.Paladin.Feature.Hammer_of_Justice()
		end
	end

end